﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TTSoft.MyWeb.Helpers
{
    #region Using
    using System.Web.Mvc;
    #endregion

    public static class HtmlHelpers
    {
        public static string Truncate(this HtmlHelper helper, string input, int length)
        {
            if (input.Length > WebConfiguration.InfoContentLength)
            {
                input = input.Substring(0, WebConfiguration.InfoContentLength);
            }

            int lastPos = input.LastIndexOf(" ");
            if (lastPos == -1)
                return "...";
            return input.Substring(0, lastPos) + "...";
        }
    }
}